package china.z.console.config.datasources.dynamic;

import china.z.console.config.datasources.DataSourceContextHolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * @author zengyz
 * @date 2018-01-01
 *  获取数据源
 */
public class DynamicDataSource extends AbstractRoutingDataSource {
    private static final Logger LOG = LoggerFactory.getLogger(DynamicDataSource.class);

    @Override
    protected Object determineCurrentLookupKey() {
        LOG.debug("数据源为{}", DataSourceContextHolder.getDatasource());
        return DataSourceContextHolder.getDatasource();
    }

}
